/**
 * Created by zhaomi on 16/5/16.
 */
var conn=require('../conf/mysql')
module.exports={
    getChooseTopicById:function(chooseId,cb){
        var options={
            sql: 'select tea_class_course_topic.id as topicId,answer from tea_class_course_topic,topic_choose where tea_class_course_topic.id=? and tea_class_course_topic.topic_choose=topic_choose.id',
            params: [chooseId],
            handle: function(topic){
                cb(topic)
            }
        }
        conn.execQuery(options)
    },
    getAnswerQuestionByLessonIdAndStudent:function(lessonId,student,topicId,cb){
        var options={
            sql: 'select id from answer_question where lesson_id=? and student=? and answer_topic=?',
            params: [lessonId,student,topicId],
            handle: function(result){
                cb(result)
            }
        }
        conn.execQuery(options)
    },
    updateAnswerQuestionByLessonIdAndStudent:function(istrue,answer_time,answer_use_time,emoji,id,answer,cb){
        var options={
            sql: 'update answer_question set istrue=?,answer_time=?,answer_use_time=?,emoji=?,answer=? where id=?',
            params: [istrue,answer_time,answer_use_time,emoji,answer,id],
            handle: function(result){
                cb(result)
            }
        }
        conn.execQuery(options)
    }
}